//
//  CommonDefines.h
//  dilidili
//
//  Created by 范月成 on 2017/12/5.
//  Copyright © 2017年 fancy. All rights reserved.
//

#ifndef CommonDefines_h
#define CommonDefines_h

#ifdef DEBUG
# define DEBUGLog(format, ...) NSLog((@"[文件名:%s]" "[函数名:%s]" "[行号:%d]" format), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DEBUGLog(...);
#endif

#define UserDefaultsForKey(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define UserDefaultsSetForKey(key,value) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]
#define UserDefaultsSynchronize() [[NSUserDefaults standardUserDefaults] synchronize]

#define kColorRGB(R,G,B,al)    [UIColor colorWithRed:R green:G blue:B alpha:al]

#define kColorMake(R,G,B,al) \
[UIColor  colorWithRed:(R)/255.0 \
                 green:(G)/255.0 \
                  blue:(B)/255.0 \
                 alpha:1.0]
#define kSystemFont(float)     [UIFont systemFontOfSize:float]
#define kSystemBoldFont(float) [UIFont boldSystemFontOfSize:float]

#define kImage(name) [UIImage imageNamed:name]
#define kIPhoneX     (kScreenHeight == 812)

#define  kAdjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

#endif /* CommonDefines_h */
